//
//  YHAutoScrollCanvas.h
//  ThunderWarriors
//
//  Created by mac on 13-6-20.
//
//

#ifndef __ThunderWarriors__YHAutoScrollCanvas__
#define __ThunderWarriors__YHAutoScrollCanvas__

#include "cocos2d.h"
#include "YHLayer.h"
USING_NS_CC;

const int KTagCanvas0 = 110;
const int KTagCanvas1 = 111;
const int KTagCanvas2 = 112;

class YHAutoScrollCanvasDelegate {
public:
    virtual void WillRenderCanvas();
    virtual void RenderCanvas(CCPoint pos) = 0;
    virtual void DidEndRenderCanvas();
};



class YHAutoScrollCanvas : public YHLayer {
public:
    static YHAutoScrollCanvas* createWithSize(CCSize size);
    YHAutoScrollCanvas();
    bool initWithSize(CCSize size);
    virtual ~ YHAutoScrollCanvas();
    /*开始滚动，speed表示速度*/
    void beginAutoScroll(float speed);
    void stopAutoScroll();
    void setDelegate(YHAutoScrollCanvasDelegate* delegate);
    //每隔t时间渲染刷新
    void beginRenderCanvas(float t);
 
    
    
    CC_SYNTHESIZE(CCRenderTexture*, m_canvas0, Canvas0);
    CC_SYNTHESIZE(CCRenderTexture*, m_canvas1, Canvas1);
    CC_SYNTHESIZE(CCRenderTexture*, m_canvas2, Canvas2);
    
    CC_SYNTHESIZE(YHAutoScrollCanvasDelegate*, m_AutoScrollCanvasDelegate, AutoScrollCanvasDelegate);
    
    CREATE_FUNC(YHAutoScrollCanvas)
    CREATE_FUNC_LAYER_WITHID(YHAutoScrollCanvas)
    DECLARE_CREATE_CLASS(YHAutoScrollCanvas)
    
protected:
    //tag表示下一个要渲染的canvas
    void renderCanvas(CCNode* canvas);
    
private:
    CCSize m_canvasSize;
    bool m_isAutoScroll;
};



#endif /* defined(__ThunderWarriors__YHAutoScrollCanvas__) */
